package com.wd.util

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit

/**
 * 作者: 黄宋祥
 * 时间: 2024/9/9  9:19
 * 描述:
 */
class HttpUtils {
    companion object{
        val httpUtils: HttpUtils by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
            HttpUtils()
        }
    }

    var client=OkHttpClient.Builder()
        .writeTimeout(5,TimeUnit.SECONDS)
        .connectTimeout(5,TimeUnit.SECONDS)
        .readTimeout(5,TimeUnit.SECONDS)
        .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
        .build()

    var build=Retrofit.Builder()
        .client(client)
        .baseUrl("http://10.59.9.24/")
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build()

    var apiService=build.create<com.wd.base.ApiService>()

    var build2=Retrofit.Builder()
        .client(client)
        .baseUrl("http://10.59.9.18/")
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build()

    var apiService2=build2.create<com.wd.base.ApiService>()
}